package loads

import (
	"gvm/instructions/base"
	"gvm/rtda"
)

type ILOAD struct {
	base.Index8Instruction
}

func (self *ILOAD) Execute(jframe *rtda.JFrame) {
	_iload(jframe, self.Index)
}

func _iload(jframe *rtda.JFrame, index uint) {
	val := jframe.LocalVars().GetInt(index)
	jframe.OperandStack().PushInt(val)
}

type ILOAD_0 struct {
	base.NoOperandsInstruction
}

func (self *ILOAD_0) Execute(jFrame *rtda.JFrame) {
	_iload(jFrame, 0)
}

type ILOAD_1 struct {
	base.NoOperandsInstruction
}

func (self *ILOAD_1) Execute(jFrame *rtda.JFrame) {
	_iload(jFrame, 1)
}

type ILOAD_2 struct {
	base.NoOperandsInstruction
}

func (self *ILOAD_2) Execute(jFrame *rtda.JFrame) {
	_iload(jFrame, 2)
}

type ILOAD_3 struct {
	base.NoOperandsInstruction
}

func (self *ILOAD_3) Execute(jFrame *rtda.JFrame) {
	_iload(jFrame, 3)
}
